// 导入实例化仓库函数
import { createStore, applyMiddleware } from 'redux'
// 导入中间件
import thunk from 'redux-thunk'
// 导入chrome插件配置
import { composeWithDevTools } from 'redux-devtools-extension'
// 导入reducer
import reducer from './reducer'
// 实例化仓库
let middlewares
// console.log(process.env.NODE_ENV)
if (process.env.NODE_ENV === 'production') {
  // 生产环境，只启用 thunk 中间件
  middlewares = applyMiddleware(thunk)
} else {
  middlewares = composeWithDevTools(applyMiddleware(thunk))
}
const store = createStore(reducer, middlewares)
export default store
